Model I ROM Explained - Part 3
Page Customization
Disassembly Navigation
Disassembly (2xxxH)
2003 - UE ERROR entry point - "GOERR"
2008-2038 - LEVEL II BASIC AUTO ROUTINE - "AUTO"
According to the original ROM source code, the AUTO [beginning line,[increment]] command is used to automatically generate line number for lines to be inserted. The beginning line is used to specify the initial line (and if omitted, defaults to 10) and the increment is used to specify the increment used to generate the next line number. If only a comma is used after the beginning line, the old increment is used.
On entry, Z will be set if there was nothing following the command.
At this point, DE points to the current character in the BASIC line being processed, "10" is in HL, and the initial number is on the STACK.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
Note: 40E4H-40E5H holds AUTO increment
Note: 40E4H-40E5H holds AUTO increment
Note: 40E2H-40E3H holds Current BASIC line number
2039-2066 - LEVEL II BASIC IF ROUTINE - "IF"
. If they match, the Z FLAG is set, and otherwise the NZ FLAG is set. If A < the checked value, then the C FLAG is set. If A >= the checked value, the NC FLAG is set.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2056H - LEVEL II BASIC ELSE ROUTINE - "FALSIF"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2067-206E - LEVEL II BASIC LPRINT ROUTINE - FOR v1.0 ONLY - "LPRINT"
206F-2177 - LEVEL II BASIC PRINT@ ROUTINE - FOR v1.0 ONLY - "PRINT"
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
- Note: 409CH holds the current output device type number (-1=cassette, 0=video; or 1=printer)
Note: 409BH holds the printer carriage position
20DDH - LEVEL II BASIC PRINT@ ROUTINE - Jumped here if we are sure we are using the display - "ISTTY"
Note: 409DH holds the size of line on the video display
Note: 40A6H holds the current cursor line position
Note: 40A6H holds the current cursor line position
20FE - This routine outputs a carriage return (0DH) to a device determined by flag stored at (409CH) - "CRDO"
NOTE: This routine may be CALLed at 20F9H, in which case it will not perform the above action if the video display cursor is already positioned at the beginning of a line, as determined by checking the contents of the cursor position flag at 40A6H (if zero, cursor is at start of line). This routine CALLs the routine at 032AH and also CALLs a Disk BASIC link at 41D0H.
2108 - This is the jump point for a continuation of the PRINT# code - "COMPRT"
- Note: 409CH holds the current output device type number (-1=cassette, 0=video; or 1=printer)
- M will be set if the value in A is negative.
- P will be set if the value in A is positive or zero.
Note: 409BH holds the printer carriage position
Note: 409EH holds the size of line on the printer
Note: 40A6H holds the current cursor line position
2137 - TAB logic - "TABER"
This routine is the TAB function for video or printer (determined by flag at 409CH). On entry: E Register contains desired TAB position, HL points to start of message to be displayed (or zero byte if no message). This routine does extensive string processing and may not be the most efficient method of achieving the desired result, particularly if it is desired only to tab over a number of spaces. Also, this routine CALLs several Disk BASIC links which may have to be "plugged". 2169 - Reset device type flag at 409CH to zero (output to video display), also turns off cassette drive if necessary. CALLs Disk BASIC link at 41BEH prior to return.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
- NOTE 1: The cursor position cannot be moved backward by this procedure. If n is not greater than the current cursor position on the line, no change will occur.
- NOTE 2: To locate the cursor at a given position on the screen (the function of the PRINT@ command in BASIC), the simplest procedure is to modify the cursor position bytes, which are located at 4020H-4021H. The address contained in these memory cells is that of the position in video memory (3C00H-3FFFH) at which the (abstract) cursor resides. This cursor position controls subsequent printing via the subroutine at 28A7H
- DISK SYSTEM CAUTION: The subroutine at 213FH has three exits to DISK BASIC, with RAM transfer points at 41BEH, 41C1H, and 41D3H. To use this routine safely, either be certain that DISK BASIC is in place, or have your assembly language program fill locations 41BEH, 41C1H, and 41D3H with RET's (C9H), before calling the routine.
- Note: 409CH holds the current output device type number (-1=cassette, 0=video; or 1=printer)
Note: 409BH holds the printer carriage position
2153H - Displaying to Screen - "TTYIST"
Note: 40A6H holds the current cursor line position
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2169 - This routine resets the device type flag at 409CH to zero (output to video display), also turns off cassette drive if necessary. CALLs Disk BASIC link at 41BEH prior to return - "FINPRT"
- Note: 409CH holds the current output device type number (-1=cassette, 0=video; or 1=printer)
- Note: 409CH holds the current output device type number (-1=cassette, 0=video; or 1=printer)
2178-217E - MESSAGE STORAGE LOCATION FOR REDO MESSAGE
- "TRYAGN"
217F-2285 - LEVEL II BASIC INPUT AND READ ROUTINES - "TRMNOK"
This is a multi-purpose processing routine. We can wind up here because DATA was typed in or DATA statements were improperly formatted. We can also wind up here where we want an INPUT to start again. If we are here because of a READ, throw a ?SN ERROR at the data line.
Note: 40DEH holds READ flag
Note: 40A9H holds Cassette input flag
Note: 40E6H-40E7H is a common temporary storage location
219A - INPUT logic - "INPUT"
Note: 40A9H holds cassette input flag
Note: 40A7H-40A8H holds the input Buffer pointer
Note: 40A7H-40A8H holds the input Buffer pointer
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
21EF - READ logic - "READ"
Note: 40FFH-4100H holds READ pointer
Note: 40DEH holds READ flag
A note in the original ROM source code indicates that when processing DATA and READ, we keep one pointer which points to the data being fetched, and another pointer which points to the lists of variables. The data pointer will always start by pointing to a terminator (either a "," a ":" or an END OF LINE).
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
A note in the original ROM source code indicates that if we are here, we have a variable which is expecting data, so we only have two choices - get it some data or complain about it not getting expected data.
Note: 40DEH holds READ flag
Note: 40A9H holds Cassette input flag
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
- NOTE: 0E65H converts the ASCII string pointed to by HL to its double precision equivalent; with output left in ACCumulator).
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
226A-226E - For ROM v1.0 - Test for FD Error
Removed in ROM v1.2 because this was not needed.
Note: There is no ROM call to this location; it operates only as passing down from the above routine. A FD ERROR means that bad file data was read as part of the READ command reading from cassette.
Note: 40A9H holds Cassette input flag
*226A-226E - For ROM v1.2 - Replaced with NOPS
Note: 40DEH holds READ flag
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
2286-2295 - MESSAGE STORAGE LOCATION - "EXIGNT"
2296-22B5 - FIND THE NEXT DATA STATEMENT ROUTINE - "DATLOP"
The original ROM source notes that the search is mad by uising the execution code for DATA to skp over statements. The start word of each statement is compared against $DATA. Each new line number is stored in DATLIN so that if an error occurs while reading data, the error message can give the line number of the bad formatted data.
Note: 40DAH-40DBH holds DATA line number
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
22B6-2336 - LEVEL II BASIC NEXT ROUTINE - "NEXT"
The original ROM source notes that a FOR entry on the STACK has the following format:
- LOW ADDRESS
- Token ($FOR in high byte) - 1 Byte
- Pointer to the loop variable - 2 Bytes
- A Byte reflecting the sign of the increment - 1 Byte
- Step value - 4 bytes
- Upper limit of FOR loop - 4 bytes
- Line number of the FOR statement - 2 bytes
- Text pointer to the FOR statement - 2 bytes
- HIGH ADDRESS
NOTE: The routine at 0A0CH algebraically compares the single precision value in BC/DE to the single precision value ACCumulator.
The results are stored in A as follows:
| Condition | Register A |
| If ACCumulator = BCDE | 00 |
| If ACCumulator > BCDE | 01 |
| If ACCumulator < BCDE | FF |
22EAH - Part of the NEXT code, where we process the variable as an integer - "INTNXT"
Note: 40AFH holds Current number type flag
If DE > HL then A will be -1;
If DE < HL then A will b +1; and
If DE = HL then A will be 0
2313H - Part of the NEXT code, jumped to continue after skipping over the integer processing - "FINNXT"
2313H - Part of the NEXT code, jumped if we haven't hit the TO counter yet - "LOOPDN"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2335-27C8 - EVALUATE EXPRESSION - "FRMPRN" and "FRMEVL"
According to the original ROM source, this routine starts with HL pointing to the first character of a formula. At the end of the routine HL points to the terminator, and ACC holds the result. Important to note that on exit Register A does not necessarily reflect the terminating character.
The formula evaluator uses the operation table ("OPTAB") to determine the precedent and to dispatch addresses for each operator.
- The RETURN location on completion (RETAOP)
- The floating point temporary result
- The address of the operator routine
- The precedence of the operator
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
Note: 40F3H-40F4H is a temporary storage location
Note: 40F3H-40F4H is a temporary storage location
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
E Token
0 +
1 -
2 *
3 /
4 @@
5 AND
6 OR
Note: 40AFH holds Current number type flag
According to the original ROM source code, the following will push the current value in the ACC onto the STACK EXCEPT in the case of a string, in which case it will throw a TYPE MISMATCH error. Registers D and E are preserved. This routine is also used in the user-defined function value savings
Note: 40AFH holds Current number type flag
Note: 411DH-4124H holds REG l
Note: 40D8H-40D9H holds Temporary storage location
23D4-23D6 - Part of the Evaluation Routine - "EPSTK"
Per the original ROM source, for exponentiation, we want to force the current value in the ACCumulator to be single precision. When application time comes, we force the right hand operand to single precision as well.
23D4-23D6 - Part of the Evaluation Routine - "ANDORD"
According to the original ROM source, for AND and OR and \ and MOD we want to force the current value in the ACCumulator to be an integer, and at application time force the right hand operator to be an integer as well.
23D4-23D6 - Part of the Evaluation Routine - "FINREL"
According to the original ROM source, this routine will build an entry for a relational operator strings are treated specially. Numeric compares are different from most operator entries only in the fact that at the bottom instead of having RETAOP, DOCMP and the relational bits are stored. Strings have STRCMP, the pointer at the string descriptor, DOCMP and the relational bits.
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
2406 - Part of the Evaluation Routine - "APPLOP"
According to the original ROM source code, APPLOP is returned to when it is time to apply an arithmetic or numeric comparison operation. The STACK has a double byte entry with the operator number and the VALTYP of the value on the STACK. APPLOP decides what value level the operation will occur at, and converts the arguments. APPLOP uses different calling conventions for each value type:
- integers: left in [d,e] right in [h,l]
- singles: left in [b,c,d,e] right in the fac
- doubles: left in fac right in arg
Note: 40B0H holds Temporary storage location
Note: 40AFH holds Current number type flag
At this point, the number in the STACK MUST be an integer.
2438 - Part of the Evaluation Routine - "STKDBL"
According to the original ROM source code, at this point we know the STACK operand is double precision, so the number in the ACC must be forced into double precision, then moved into ARG and the STACK value POPped into ACC.
Note: 411DH-4124H holds the ACCumulator
LD A,(DORES) 3A B0 40
Note: 40B0H holds Temporary storage location
2460H - Part of the Evaluation Routine - "FACDBL"
According to the original ROM source code, at this point the ACCumulator holds a double precision numbe, and the STACK holds either an integer or a single precision number, so we need to convert it.
Note: 40AFH holds Current number type flag
2472H - Part of the Evaluation Routine - "STKSNG"
According to the original ROM source code, at this point the STACK holds a single precision number, we know that the ACCumulator holds either an integer or a single precision number, so we need to convert it.
247CH - Part of the Evaluation Routine - "FACSNG"
According to the original ROM source code, at this point the ACCuumulator holds a single precision number and the STACK holds an integer.
2490 - Integer divide - "INTDIV"
(ACC=DE / HL) Result will be in single-precision (NTF=4) and will be in the ACC.
Divides DE by HL. Both values are converted to single precision before the division is started. The quotient is left in REG l; the mode flag is updated. The orginal contents of the DE and HL Register sets are lost
The original ROM source code points that we can't just live in integer world here, because we want 1/3 to be .3333 and not 0! So all arguments must be single precision even if they are integer
Integer Division: Divides DE by HL. Both values are converted to single precision before the division is started. The quotient is left in the ACCumulator; the mode flag is updated. The orginal contents of the DE and HL Register sets are lost
Single Precision Divide Divides the single precision value in (BC/DE) by the single precision value in the ACCumulator. The quotient is left in the ACCumulator.
249F - Evaluate a Variable, Constant, or Function Call - "EVAL"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Notes:
- 22H is a " . If they match, the Z FLAG is set, and otherwise the NZ FLAG is set. If A < the checked value, then the C FLAG is set. If A >= the checked value, the NC FLAG is set.
Notes:
- C3H is a ERR token.
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 409AH holds the RESUME flag
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40EAH-40EBH holds the line number with error
24E7-24FE VARPTR logic - "NTERL"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
24FF - Other Function Routine - Jumped here if it wasn't VARPTR to see what else it might have been - "NTVARP"
252CH - Other Function Routine - If we pass through to here, the only other possibility is that it is a function in parenthesis - "PARCHK"
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2532 - Binary Minus Routine - "DOMIN"
Note: 40F3H-40F4H is a temporary storage location
2540 - Math Routine - "ISVAR"
According to the original ROM source code, this routine loads a variable to the ACC and sets the NTF. The HL must point to the ASCII variable name. After execution the HL will point to the character following the last character of the variable used. The value of the variable will be loaded in the ACC. For strings however (NTF=3), the ACC will contain the address of the first three bytes which contain the string length and string address (see Level II BASIC manual). Also note that if the variable cannot be found it will be created and given a value of zero.
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
254E - This routine processes an expression for SNG( to MID$( - "ISFUN"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The original source code has this to say about being here:
Most functions take a single argument. The return address of these functions is a small routine that checks to make sure valtyp is 0 (numeric) and pops off the text pointer. so normal functions that return string results (i.e. chr$) must pop off the return address of labbck, and pop off the text pointer and then return to FRMEVL.
The so called "funny" functions can take more than one argument, the first of which must be string and the second of which must be a number between 0 and 256. The text pointer is passed to these functions so additional arguments can be read. The text pointer is passed in Register Pair DE. The close parenthesis must be checked and return is directly to FRMEVL with Register Pair HL setup as the text pointer pointing beyond the ")".
The pointer to the descriptor of the string argument is stored on the STACK underneath the value of the integer argument (2 bytes).
The first argument is ALWAY a string. The second is always an integer.
The original source code has this to say about being here:
We next have to check to see if a special coercion must be done for one of the transcendental functions ( RND , SQR , COS , SIN , TAN , ATN , LOG , and EXP ).
Since these functions do not look at VALTYP, but rather assume the argument passed in the ACCumulator is single precision, we MUST call FRCSNG before dispatching to them.
258C - Part of the Formula Evaluation Code - "STRCMP"
According to the original ROM source, this routine will compare two strings, one with the description in Register Pair DE and the other in FACLO/FACLO+1. On exit:
- A = 0 if the strings are equal
- A = 377 if BCDE > FACLO
- A = 1 if BCDE < FACLO
This routine will do a relational comparison of two strings.
It will load A with the length of the first string and BC with the string's address. Then it will load D with the length of the second string and HL with the string's address.
If the values match, set the current result in zero. If they do not match, set the current result to -1
25C4 - NOT Routine - "NOTER"
25D9 - The RST 20H code - "GETYPR"
This is the TEST DATA MODE, which determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).TYPE CODE ZERO CARRY NEG PARITY A-Register
INT 02 NZ C N E -1
STR 03 Z C P E 0
SNG 04 NZ C P O 1
DBL 08 NZ NC P E 5
Note: 40AFH holds Current number type flag
25E9 - AND and OR Routines - "DANDOR"
According to the original ROM source, this routine applies the AND and OR operators and should be used to implement all logical operators
Whenever an operator is applied, its precedence is in Register B
This fact is used to distinguish between AND and OR
The right hand argument is coerced to integer, just as the left hand one was when it was pushed on the STACK
25F7 - OR logic.
25FD - AND logic - "NOTOR"
2603 - Dimension and Variable Searching Routine - "DIMCON"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2608 - DIM logic - "DIM"
The original ROM source code states that this DIM code sets DIMFLG and then falls into the variable search routine, which then looks at DIMFLG at three different points:
- If an entry is found, dimflg being on indicates a "doubly dimensioned" variable
- When a new entry is being built dimflg's being on indicates the indices should be used for the size of each indice. otherwise the default of ten is used.
- When the build entry code finishes, only if dimflg is off will indexing be done
260D - Variable location and creation logic - "PTRGET"
The original ROM source code states that this routine will read the variable name at the current text position and put a pointer to its value in Register Pair DE. Register Pair HL is then updated to point to the character after the variable name and VALTYP is set up. Evaluating subscripts in a variable name can cause recursive calls to PTRGET so at that point all values must be stored on the STACK. On RETurn, [a] does not reflect the value of the terminating character.
This routine will return the address of a variable in memory or create it if it is not found. In order to use this routine, the HL must point to the variable name (ASCII). Then, after execution, HL will point to the character following the variable name and the location of the variable will be returned in the DE Register Pair. For integer, single or doubleprecision (NTF=2, 4 or 8) the address returned in DE will be the same as for the VARPTR command under BASIC. (see Level II BASIC manual on VARPTR) For strings (NTF=3) however the address returned in DE will point to the first of three bytes containing the string length and string address.
This entry point searches the Variable List Table (VLT) for a variable name which matches the name in the string pointed to by HL. If the variable exists, its address is returned in DE. If it is not defined, then it is created with an initial value ofzero and its address is returned in DE. Dimensioned and non-dimensioned variables may be located, and suffixs for data mode may be included in the name string. A byte of machine zeros must terminate the name string. All registers are used.
Note: 40AEH holds LOCATE/CREATE variable flag
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
NOTE: 4101H-411AH holds Variable Declaration Table
NOTE: 40AFH holds Current number type flag
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40DCH holds FOR flag
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40FDH-40FEH holds Free memory pointer
NOTE: 40FDH-40FEH holds Free memory pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
26D5 - This routine is ZERO out all variable types and skip any RETurn - "FINZER"
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
26E9 - This routine handles a subscripted variables - "ISARY"
According to the original ROM source, ARRAYs have the following format:
- Descriptor - Low Byte - Second Character (200 bit is string)
- Descriptor - High Byte - First character
- Length of array in core in bytes
- Number of dimensions (1 byte)
- Then, for each dimension starting with the first, a list of the max index+1 (2 bytes each)
- The associated value
Note: 40AEH holds LOCATE/CREATE variable flag and will be a 0 if in locate mode and anything other than zero if in create mode
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: 40AEH holds LOCATE/CREATE variable flag
At this point, Register BC holds the variable name, the pointer to the BASIC program is in TEMP2, all of the indexes are on the STACK, as is the number of dimensions.
Note: 40FDH-40FEH holds Free memory pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40AFH holds Current number type flag
Note: 40AEH holds LOCATE/CREATE variable flag
At this point TEMP2 still holds the pointer to the position in the BASIC line being evaluated AND we have located the variable we were looking or. HL will point beyond the LENGTH to the number of dimensions. All indices are on the STACK, followed by the number of dimensions.
273D - ?BS ERROR entry point - "BSER"
2742 - Part of the ARRAY routines. Jumped here when a variable isn't found in the ARRAY table - "NOTFDD"
The original ROM source lays out the steps which the ROM takes to build an entry when a variable isn't found in the array table:
- Get an index
- Put number+1 down at the VARPTR
- Increase the VARPTR
- Decmrent the number of DIMs
- Go back to the LOOP until the number of DIMs hits Zero
Note: 40D8H-40D9H holds temporary storage location
Note: 40AEH holds LOCATE/CREATE variable flag
CALL REASONCD 6C 19
Note: 40FDH-40FEH holds free memory pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40D8H-40D9H holds Temporary storage location
At this point, HL points beyond the SIZE of the array to the NUMBER OF DIMENSIONS in the array. So what we need to do next is
- We need NUMDIM to equal the number of dimensions and CURTOL to be 0
- Start a loop:
- Get a new index value
- Pop the new maximum into CURMAX
- Make sure the index value isn't too big
- Multiply CURTOL by CURMAX
- Add the index to CURTOL
- Reduce NUMDIM by 1
- LOOP BACK if NUMDIM isn't yet 0
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
NOTE: 40AFH holds Current number type flag
27B3
LD C,L 44
Note: 40F3H-40F4H is a temporary storage location
27C9-27D3 - LEVEL II BASIC MEM ROUTINE - "MEM"
This is the RETURN AMOUNT OF FREE MEMORY routine at 27C9H which computes the amount of memory remaining between the end of the variable list and the end of the STACK and puts the result in ACCumulator as a SINGLE PRECISION number.
NOTE: 40AFH holds Current number type flag
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
27D4-27F4 - LEVEL II BASIC FRE ROUTINE - "FRE"
NOTE: 40FDH-40FEH holds Free memory pointer
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
NOTE: 40A0H-40A1H holds the start of string space pointer
NOTE: 40D6H-40D7H holds the next available location in string space pointer
The next routine subtracts DE from HL and then floats the result leaving it in FAC.
27F5-27FD - LEVEL II BASIC POS( ROUTINE - "POS"
Note: 40A6H holds the current cursor line position
27FE-2818 - LEVEL II BASIC USR(x) ROUTINE - "USRFN"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40AFH holds Current number type flag
(02=INT, 03=STR, 04=SNG, 08=DBL)
2819-2827 - CONVERSION ROUTINE - "DOCNVF"
Usually called by LET to convert the result of arithmetic routines to the proper destination type.
(02=INT, 03=STR, 04=SNG, 08=DBL)
2828-2835 - Routine to see if we are in DIRECT MODE and ERROR OUT if so - "ERRDIR"
Usually called from the INPUT routine. On entry HL has the current line number in binary.
2831 - ID ERROR entry point.
2836-2856 - STRING ROUTINE - STR$ logic - "STR$"
The next routine, STRCPY, creates a copy of the string pointed to by Register Pair HL. On exit, DE points to DSCTMP which has the string information.
2857-2864 - STRING ROUTINE - "STRINI"
Note: 40D3H-40D5H holds Used for temporary string VARPTR's
2865-28A5 - STRING ROUTINE - "STRLIT"
STRLT2 takes the string literal whose first character is pointed by HL+1 and builds a descriptor for it. Leading quotes should be skipped before the CALL to this routine.
The descriptor is initially built in DSCTMP, but PUTNEW transfers it into a temporary RAM area and leaves a pointer at the temporary in FACLO.
All characters other than zero (that terminate the string) should be set up in Registers B and D. If the terminator is a quote, the quote is skipped over.
On EXIT, the character after the string literal is pointed to by Register Pair HL and is in Register A. No flags are set.
Note: 40D3H-40D5H holds Used for temporary string VARPTR's
Note: 40B3H-40B4H holds the next available location in the temporary string work area pointer
Note: 40AFH holds current number type flag
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40B3H-40B4H holds the next available location in the temporary string work area pointer
28A1 - ST ERROR entry point.
28A6-28BE - DISPLAY MESSAGE ROUTINE - "STROUI"
According to the original ROM source, this routine will print the string pointed to by Register Pair HL. The string MUST be terminated by a 00H. If the string exists below DSCTMP, then it is copied into string space first.
EXAMPLE: Suppose that we have the following symbolic setup:
TITL DEFM 'INSIDE LEVEL II'
DEFB 0
Then, the instructions:
LD HL,TITL
CALL 28A7H
will cause "INSIDE LEVEL II" to be displayed at the current cursor position and the cursor position to be updated.
"STROUT"
If the routine entry is at STRPRT, then it just prints the string whose descriptor is held in FACLO
28BF-28D9 - STRING ROUTINE - "GETSPA"
This routine will get space for a character string, and it might force garbage collection as well. The number of characters is in Register A. On exit, DE will point to the string, but if it could not allocate space, then an ?OS ERROR is thrown instead.
Note: 40D6H-40D7H holds the next available location in string space pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
28DA-298E - STRING ROUTINE - "GARBAG"
Note: 40B1H-40B2H holds MEMORY SIZE? pointer
Note: 40D6H-40D7H holds the next available location in string space pointer
NOTE: 40A0H-40A1H holds the start of string space pointer
Note: 40B5H-40D2H holds Temporary string work area
"TVAR"
NOTE: 40B3H-40B4H holds the next available location in the temporary string work area pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
NOTE: 40F9H-40FAH holds the starting address of the simple variable storage area
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40FDH-40FEH holds Free memory pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40D8H-40D9H holds Temporary storage location
Note: 40D8H-40D9H holds Temporary storage location
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2954
LD C,L 44
NOTE: 40D6H-40D7H holds the next available location in string space pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
295A
LD L,C 60
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2962
LD L,C 60
If we are here, we have made one complete pass through the string variables.
NOTE: 40D6H-40D7H holds the next available location in string space pointer
298F-29C5 - STRING ADDITION ROUTINE - Concatenate two strings - "CAT"
This routine concatenates two strings. The first is pointed to by FACLO and HL points to the character after the "+" sign in on the command line.
29C6-29D6 - STRING ROUTINE - This will move strings using the STACK - "MOVINS"
On entry, the STACK should have the count/source address and DE should have the destination address
29C8 - STRING MOVE ROUTINE
On entry HL points to the string control block for the string to be moved, and DE contains the destination address. All registers are used. The string length and address are not moved. String control blocks have the format: X=String Length; ADDR = String Address.
29D7-29F4 - STRING ROUTINE - "FRESTR"
According to the original ROM source code, FRETMP is passed a pointer to a string descriptor in Register Pair DE and is returned in Register Pair HL. All the other registers are modified. A check to is made to see if the string descriptor in Register Pair DE points to is the last temporary descriptor allocated by PUTNEW. If so, the temporary is freed up by the updating of TEMPPT. If a temporary is freed up, a further check is made to see if the string data that that string temporary pointed to is the the lowest part of string space in use. If so, FRETMP is updated to reflect the fact that that space is no longer in use.
This routine is a contination of VAL , FRE , and PRINT processing. A jump to here would include the need to get a string's VARPTR and put it in HL.
Note: 40D6H-40D7H holds the next available location in string space pointer
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40D6H-40D7H holds the next available location in string space pointer
29F5-2A02 - STRING ROUTINE - - "FRETMS"
Test to see if the string in DE is the last string used in the temporary string work area.
Note: 40B3H-40B4H holds the next available location in the temporary string work area pointer
NOTE: The RST 18H routine The result of the comparison is returned in the status Register as:
| Condition | Flag |
| If HL < DE | CARRY SET |
| If HL > DE | NO CARRY |
| If HL ≠ DE | NZ |
| If HL = DE | Z |
Note: 40B3H-40B4H holds the next available location in the temporary string work area pointer
2A03-2A0E - LEVEL II BASIC LEN ROUTINE - "LEN"
2A0F-2A1E - LEVEL II BASIC ASC ROUTINE - "ASC"
2A1F-2A2E - LEVEL II BASIC CHR$ ROUTINE - "CHR$"
2A2F-2A60 - LEVEL II BASIC STRING$ ROUTINE - "STRNG$"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 20H routine determines the type of the current value in ACCumulator and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
2A61-2A90 - LEVEL II BASIC LEFT$( ROUTINE - "LEFT$"
On entry, HL=address of LEFT$$, the STACK = string address, STACK+1 = n, and DE = code string address.
2A91-2A99 - LEVEL II BASIC RIGHT$ ROUTINE - "RIGHT$"
2A9A-2AC4 - LEVEL II BASIC MID$ ROUTINE - "MID$"
The original ROM source code clarifies that if the number provided is greater than the actual length of the string, a NULL value is returned. If the second number (the number of characters) exceeds the end of the string, the maximum amount of available characters are returned.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2AC5-2ADE - LEVEL II BASIC VAL ROUTINE - "VAL"
The original ROM source explains that we need to do some fancy footwork here to handle the case where the two strings are stored next to each other.
2ADF-2A6 - STRING ROUTINE - "PREAM"
This is called by LEFT$ , MID$ , and RIGHT$ to test for the ending ")" character. On entry, the STACK has the string address, byte count, and return address. On exit the STACK has the string address, DE and B each have the byte count.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2AE7H-2AEE - Process a LEFT-HAND-SIDE MID$ - "ISMID$"
2AEF-2AF7 - LEVEL II BASIC INP ROUTINE - "FNINP"
2AF8-2B00 - LEVEL II BASIC OUT ROUTINE - "FNOUT"
2B01-2B0D - EVALUATE EXPRESSION ROUTINE
"GETINT"
This evaluates an expression and leaves the result in DE as an integer.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2B05 - This routine takes the value from the ACC, converts it to an integer value and places the result in the DE Register Pair. The Z flag will be set if the result in DE is smaller than or equal to 255 (FFH). (DE = INT (ACC)).
2B0E-2B16 - EVALUATE EXPRESSION ROUTINE - OUT continues here - "SETIO"
2B17-2B1A - CHECK SYNTAX ROUTINE - This checks to see if the next character is a " and contnues on to 2B1CH if it is, and errors out if it isn't.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2B1B-2B28 - EVALUATE EXPRESSION ROUTINE - This is called by PRINT TAB - "GTBYTC"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2B1C - Common Conversion Routine - "GETBYT"
This routine converts a numeric ASCII string pointed to by the HL into a hexadecimal value and places the result in the A register. If the result is larger than 255 (FFH) then an FC ERROR (Illegal function call) will be generated. After execution the HL will point to the delimiter. If the delimiter is a zero byte or a colon (3AH) then the Z flag will be set. Any other delimiter will cause the Z flag to be reset.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2B29-2B2D - LEVEL II BASIC LLIST ROUTINE - "LLIST"
This routine sets the output device flag to PRINTER and then flows through to the LIST command.
Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer
2B2E-2B74 - LEVEL II BASIC LIST ROUTINE - "LIST"
On entry the STACK has the return address, then the first basic line number to be listed, then the last basic line number to be listed.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
Note: 40ECH-40EDH holds EDIT line number
Note: 40A7H-40A8H holds the input Buffer pointer
2B75-2B7D - DISPLAY MESSAGE ROUTINE - "LISPRT"
This is the PRINT MESSAGE routine which writes string pointed to by HL to the current output device. String must be terminated by a byte of zeros. This call is different from 28A7H because it does not use the literal string pool area, but it does use the same display routine and it takes the same DOS Exit at 41C1H. Uses all registers. This routine can be called without loading the BASIC utility, if a C9H (RET) is stored in 41C1H.
This routine outputs a string to device indicated by device type flag stored at 409CH. String must end with zero byte. On entry, HL registers must point to address of start of string. Calls routine at 032AH.
2B7E-2BC5 - UNTOKENIZE ROUTINE - "BUFLIN"
This routine is called by LIST and EDIT . It moves the line pointed to by HL to the input buffer area and then expands each token into the appropriate key word.
Note: 40A7H-40A8H holds the input Buffer pointer
2B83
LD C,L 44
This is where the infamous ROM bug which can crash Level II sits. It assumes that a ' has room to move backwards 4 characters, which it might not!
DEC BC
DEC BC
DEC BC 0B
INC D
INC D
INC D 14
A REM isn't the only TOKEN with a hidden add-on. ELSE also has a hidden colon in front of it. So let's now deal with that.
2BC6-2BF4 - LEVEL II BASIC DELETE ROUTINE - "DELETE"
2BD2
LD E,L 54
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
2BF5-2C1E - LEVEL II BASIC CSAVE ROUTINE - "CSAVE"
The original ROM source code says that the CSAVE command dump's BASIC's core. Three D3H's are written, followed by a 1 character filename. At the end 3 zeros in a row are written.
- Note: 40A4H-40A5H holds the starting address of BASIC program text also known as the PROGRAM STATEMENT TABLE (PST).
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
2C1F-2CA4 - LEVEL II BASIC CLOAD ROUTINE - ROM v1.0 - "CLOAD"
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
*2C1F-2CA4 - LEVEL II BASIC CLOAD ROUTINE - ROM v1.3
Common code between ROM v1.0 and v1.2 continues here.
- Note: 40A4H-40A5H holds the starting address of BASIC program text also known as the PROGRAM STATEMENT TABLE (PST).
This loop is going to read a byte, compare it to the next byte in the program memory, jump away if it doesn't match AND CLOAD? was chosen, write (or overwrite) that byte to memory, check for a zero, and loop back if no zero was found.
CALL REASONCD 6C 19
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
- Note: 40A4H-40A5H holds the starting address of BASIC program text also known as the PROGRAM STATEMENT TABLE (PST).
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
2CA5-2CA9 - MESSAGE STORAGE LOCATION - "NOOKCS"
2CAA-2CB0 - LEVEL II BASIC PEEK ROUTINE - "PEEK"
The original ROM source code says that PEEK only accepts positive numbers up to 32767 and POKE will only take an address up to 32767. Negative numbers can be used to refer to locations higher than 32767, the correspondence is given by subtracting 65536 from locations higher than 32767 or by specifying a positive number up to 65535
On entry, ACCumulator to have the peek location, and on exit ACCumulator to have the peeked value.
2CB1-2CBC - LEVEL II BASIC POKE ROUTINE - "POKE"
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2CBD-2E52 - LEVEL II BASIC USING ROUTINE - "PRINUS"
The original ROM source code says that we wind up here after the "USING" clause in a PRINT statement is recognized. The idea is to scan the using string until the value list is exhausted, finding string and numeric fields to print values out of the list in, and just outputing any characters that aren't part of a print field
Vernon Hester has reported an error in the PRINT USING routine. A PRINT USING statement with a negative sign at the end of the field prints a negative sign after negative numbers and prints a space for positive numbers. However, if the field specifiers in the string also has two asterisks at the beginning of the field, the ROM prints an asterisk instead of a space after a positive number.
Example: PRINT USING "**####-";1234 will display **1234* instead of **1234 SPACE
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL Register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
If we are here, then a string field was not found. The "USING" string character count and the pointer into its data MUST be restored and the "\" printed.
At this point we need to print the character held in Register A since it wasn't part of any field
Now we parse all the 2 character USING fields.
NOTSPC
2D66 - Part of the PRINT USING Routine - "DOTNUM"
Jumped here when a "." is seen in the USING string. THis means that we are starting a numeric field ONLY if it is followed by a "#"
2D7A - Part of the PRINT USING Routine - "FINNUM"
Now we move on to check the "^^^^" that indicates scientific notation
2D80
LD E,L 54
2DB5 - Part of the PRINT USING Routine - "ENDNUM"
Jump point for when we figure out that we are at the end of a string of digits within a USING string
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The RST 10H routine parses the characters starting at HL+1 for the first non-SPACE,non-09H,non-0BH character it finds. On exit, Register A will hold that character, and the C FLAG is set if its alphabetic, and NC FLAG if its alphanumeric. All strings must have a 00H at the end.
The original ROM source code indicates that since FRMEVL may have forced some garbage collection, we cannot rely on the pointer of characters remaining to be scanned. Instead, we have to use the number of characters scanned prior to calling FRMEVL as an offset to the "USING" string's data after FRMEVL.
2DFE-2E00 - Part of the PRINT USING Routine - "REUSIN"
We will wind up here when we are done processing a numeric field
2E14-2E15 - Part of the PRINT USING Routine - "SMSTRF"
We will wind up here when the "!" indicating a single character string field has been scanned
This loop will print all the spaces needed and then jump to 2DD3H.
2E49 - Part of the PRINT USING Routine - "PLSPRT"
When a "+" is detected in the "USING" string and a numeric field follows, a bit in Register D should be set, otherwise + should be printed. Since deciding whether a numeric field follows is very difficult, the bit is always set in Register D. At the point it is decided a character is not part of a numeric field, this routine is called to see if the bit in Register D is set, which means a plus preceded the character and should be printed
2E53-2FFA - LEVEL II BASIC EDIT ROUTINE - "ERREDT"
According to the original ROM source, the EDIT command takes a single line number as its argument. If that line doesn't exist, and error is thrown. If the line does exist, the line number is then typed, and the system waits for the user to enter any of the valid commands.
Register C holds the number of characters in the line, Register B holds the current character position (with 0 being the first character) and Register Pair HL points to the current character
Note: 409AH holds the ERROR/RESUME flag
Note: 40EAH-40EBH holds the line number with error
Now that the above code is out of the way (it was the code which would enter EDIT if there was an error in a line number), let us actually process the EDIT command
Note: 40ECH-40EDH holds EDIT/LIST line number
2E71
LD L,C 60
2E73
INC HL 23
Note: 40A7H-40A8H holds the input Buffer pointer
2EB0H - LEVEL II BASIC EDIT ROUTINE - "NOTDGI"
While getting user command input within an edit, we wind up here if the user enters a non-numeric character (i.e., the actual command, and not just the repetition number which precedes it)
That's it for non-alphabetic instructions, so we need to need to convert a lower case command to upper case
2F02 - EDIT Command - Cancel and Restore Logic.
2F0A - This routine prints a string of text to the display, printer or tape - "SPED"
This routine it uses 032AH to do this. HL must point to the first character of the string. (409CH must be set before calling this routine, see 32AH). String must be delimited with a zero byte.
Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer
2F16 - EDIT Command - KILL Logic - "KED"
2F40 - EDIT Command - LIST Logic - "LED"
2F4A - EDIT Command - DELETE Logic - "DED"
2F65 - EDIT Command - CHANGE Logic - "CED"
2F75 - EDIT Command - HACK/INSERT Logic - "HED"
2F92 - EDIT Command - BACKSPACE CURSOR Logic - "TYPARW"
2FA1 - LEVEL II BASIC EDIT ROUTINE - "DELCHR"
This subroutine will delete the character pointed to by Register Pair HL and will correct Register C
2FB0 - EDIT Command - ADD A CHARACTER Logic - "NTARRW"
2FD2 - EDIT Command - BACKSPACE Logic - "DELED"
Note: 40A7H-40A8H holds the input Buffer pointer